package xixirupan.tmgp.tencent.com.vmeim.login.presenter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import xixirupan.tmgp.tencent.com.vmeim.R;
import xixirupan.tmgp.tencent.com.vmeim.login.Model.CountriesBaen;

/**
 * Created by lenovo on 2016/10/21.
 */

public class PopwindowAdapter extends BaseAdapter {
    List<CountriesBaen> countries;
    Context context;
    LayoutInflater inflater;
    public PopwindowAdapter(Context context,LayoutInflater inflater,List<CountriesBaen> countries)
    {
        this.context =context;
        this.countries =countries;
        this.inflater =inflater;
    }
    @Override
    public int getCount() {
        return countries.size();
    }

    @Override
    public Object getItem(int position) {
        return countries.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder  holder;
        if (convertView ==null)
        {
            convertView = inflater.inflate(R.layout.item_popu_listview, parent, false);
            holder =new ViewHolder(convertView);
            convertView.setTag(holder);

        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.textView_name.setText(countries.get(position).getName()+"   "+countries.get(position).getEnName());

        return convertView;
    }
    class ViewHolder {
        TextView textView_name;
        public ViewHolder(View v)
        {
            textView_name = (TextView) v.findViewById(R.id.textView_country_pop);
        }
    }

}
